package cn.edu.ujn.park.service;

import cn.edu.ujn.park.dao.Payments;
import cn.edu.ujn.park.dao.PaymentsMapper;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class PaymentsServiceImpl implements IPaymentsService {
    @Autowired
    private PaymentsMapper paymentsMapper;

    @Override
    public int deleteByPrimaryKey(Integer paymentId) {
        return paymentsMapper.deleteByPrimaryKey(paymentId);
    }

    @Override
    public int insert(Payments row) {
        return 0;
    }

    @Override
    public int insertSelective(Payments row) {
        return 0;
    }

    @Override
    public Payments selectByPrimaryKey(Integer paymentId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Payments row) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Payments row) {
        return 0;
    }

    @Override
    public Page<Payments> selectAll(Payments payments) {
        Page<Payments> page = new Page<>();
        List<Payments> list = paymentsMapper.selectAll(payments);
        Integer count = paymentsMapper.selectCount(payments.getUserId());
        page.setRows(list);
        page.setPage(payments.getStart());
        page.setTotal(count);
        page.setSize(payments.getRows());
        return page;
    }

    @Override
    public Integer update() {
        return paymentsMapper.update();
    }

    @Override
    public Integer delete(Integer paymentId) {
        return paymentsMapper.delete(paymentId);
    }

    @Override
    public Integer pay(Integer paymentId, BigDecimal finalCost, Integer couponId) {
        return paymentsMapper.pay(paymentId, finalCost, couponId);
    }
}
